import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Scanner;

public class Dictionary 
{
	// create a private HashMap variable 
	private HashMap<String, Boolean> dictionary = new HashMap<String, Boolean>(4500);
		
	/**
	 * A constructor that takes a name of a .txt file
	 * @throws FileNotFoundException 
	 */ 
	public Dictionary() throws FileNotFoundException
	{
		Scanner scanner = new Scanner(new FileReader("DictionarySample.txt"));

		// Read file line by line and set string as key and value to true.
		while (scanner.hasNext())
		{
			// Convert input to lower-case. 
			dictionary.put(scanner.nextLine().toLowerCase(), true);
		}
		
		scanner.close();
	}
	
	/**
	 * A method that takes a string representation of the word and returns value
	 * 
	 * @param a String represents the word
	 * @return a boolean of the key's value 
	 */
	public boolean validate(String word)
	{
		return ((boolean) dictionary.containsKey(word.toLowerCase()));
	}
}
